#ifndef SRREVIEWAUDITWIDGET_H
#define SRREVIEWAUDITWIDGET_H

#include <QWidget>
#include <QMap>
class QStandardItemModel;
class QTableView;
class QCheckBox;
class QLineEdit;
class QPushButton;
class SRTransactionWidget;
class QSpinBox;
class QLabel;

class SRReviewAuditWidget : public QWidget
{
    Q_OBJECT

private:

    struct stTransaction{
        QString txid;
        QString vout;
        QString money;
        stTransaction(void):txid(""),
            vout(""),money(""){}
    };

    //
    struct stWithdrawCash {
        // 上笔交易
        QList<stTransaction> last_tr;
        QString info;
        // 私钥索引得到
        QString prv_idx;
        // 出账地址
        QString source_addr;
        // 目标入账地址
        QString dest_addr;
        // 转正金额
        QString dest_money;
        // 服务费
        double tip;
        // 是否隔离验证
        int is_verify;

        QString broadcasting;

        QString state;
        stWithdrawCash(void)
            : last_tr(),prv_idx(""),source_addr(""),
              dest_addr(""),dest_money(""),
              tip(0),is_verify(0),state("C"){}
    };

    struct stSignData {
        QString data;
        QString hex;
        stSignData(const QString& _data = "",
                   const QString& _hex = "")
            :data(_data), hex(_hex){}
    };


public:
    explicit SRReviewAuditWidget(QWidget *parent = 0);


    bool isBusy(void);

protected:


    virtual void showEvent(QShowEvent *event);
    virtual void hideEvent(QShowEvent *event);

Q_SIGNALS:

    // 总条数 总笔数
    void sigExcelDone(int,int);

    // 成功个数 失败个数
    void sigSignDone(int,int);

    void sigSignStatus(QString, bool);

public slots:


    void onExportXlsClick(void);


    void onUpdate(int idx);

    void onRowDoubleClicked(const QModelIndex& _item);



private Q_SLOTS:

    void onQuery(void);

private:

private:


private:
    void insertModelData(const QString& id,
                         const QString& audit_id,
                         const int &is_export,
                         const QString& transaction_count,
                         const QString& txid,
                         const QString& crt_time);


private:
    QLineEdit* edtAuditNum_;
    QStandardItemModel *model_;
    QTableView* tableView_;
    QPushButton* btnAllSelect_;
    QSpinBox* boxPageNum_;
    // id : sign data
    QMap<QString,stSignData> mapBroadcasting_;

    std::atomic<bool> bThreadReadExcel_;
    std::atomic<bool> bThreadSign_;

    SRTransactionWidget* pageAuditInfo_;

    QLabel* labAuditCount_;


};

#endif // SRREVIEWAUDITWIDGET_H

